package CodeOne;

import java.util.Scanner;
import java.util.Arrays;
/** @author ASUS */
public class OutSmallerNum {
  public static void main(String[] args) {
    int a, b;
    Scanner inputScan = new Scanner(System.in);
    a = inputScan.nextInt();
    b = inputScan.nextInt();
    int[] c;
    c = new int[a];
    for (int i = 0; i < a; i++) {
      c[i] = inputScan.nextInt();
    }
    Arrays.sort(c);
    for (int i = 0; i < b; i++) {
      System.out.print(c[i]);
      System.out.print(" ");
    }
  }
}
